package com.ruoyi.mes.service.impl;

import java.util.List;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.mes.utils.CodeUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.mes.mapper.PhgSupplierMapper;
import com.ruoyi.mes.domain.PhgSupplier;
import com.ruoyi.mes.service.IPhgSupplierService;

/**
 * 供应商管理Service业务层处理
 * 
 * @author CFL
 * @date 2024-04-28
 */
@Service
public class PhgSupplierServiceImpl implements IPhgSupplierService 
{
    @Autowired
    private PhgSupplierMapper phgSupplierMapper;

    /**
     * 查询供应商管理
     * 
     * @param id 供应商管理主键
     * @return 供应商管理
     */
    @Override
    public PhgSupplier selectPhgSupplierById(Long id)
    {
        return phgSupplierMapper.selectPhgSupplierById(id);
    }

    /**
     * 查询供应商管理列表
     * 
     * @param phgSupplier 供应商管理
     * @return 供应商管理
     */
    @Override
    public List<PhgSupplier> selectPhgSupplierList(PhgSupplier phgSupplier)
    {
        return phgSupplierMapper.selectPhgSupplierList(phgSupplier);
    }

    /**
     * 新增供应商管理
     * 
     * @param phgSupplier 供应商管理
     * @return 结果
     */
    @Override
    public int insertPhgSupplier(PhgSupplier phgSupplier)
    {
        BaseController baseController = new BaseController();
        String username = baseController.getUsername();
        phgSupplier.setCreatedBy(username);
        phgSupplier.setCreatedTime(DateUtils.getNowDate());
        String supplierSn = CodeUtils.supplierCodeCreat();
        phgSupplier.setSupSn(supplierSn);
        return phgSupplierMapper.insertPhgSupplier(phgSupplier);
    }

    /**
     * 修改供应商管理
     * 
     * @param phgSupplier 供应商管理
     * @return 结果
     */
    @Override
    public int updatePhgSupplier(PhgSupplier phgSupplier)
    {
        BaseController baseController = new BaseController();
        String username = baseController.getUsername();
        phgSupplier.setCreatedBy(username);
        phgSupplier.setCreatedTime(DateUtils.getNowDate());
        return phgSupplierMapper.updatePhgSupplier(phgSupplier);
    }

    /**
     * 批量删除供应商管理
     * 
     * @param ids 需要删除的供应商管理主键
     * @return 结果
     */
    @Override
    public int deletePhgSupplierByIds(Long[] ids)
    {
        return phgSupplierMapper.deletePhgSupplierByIds(ids);
    }

    /**
     * 删除供应商管理信息
     * 
     * @param id 供应商管理主键
     * @return 结果
     */
    @Override
    public int deletePhgSupplierById(Long id)
    {
        return phgSupplierMapper.deletePhgSupplierById(id);
    }
}
